package com.mantou.mantouaiagent.tools;


import com.mantou.mantouaiagent.entities.User;
import com.mantou.mantouaiagent.mapper.UserMapper;
import jakarta.annotation.Resource;
import org.springframework.ai.chat.model.ToolContext;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.stereotype.Component;

//@Component
public class CurrentUserTool {

    @Resource
    private UserMapper userMapper;

    @Tool(description = "Get the current user's name,"+"用户没有说明他是谁 且询问他是谁的时候或者默认打招呼时使用 准确得知用户名称")
    public String getCurrentUserName(ToolContext toolContext) {
        Integer userId =(Integer) toolContext.getContext().get("userId");
        User user = userMapper.selectById(userId);
        return user.getUsername();
    }
}
